package com.itheima.web.controller.oss;

import com.itheima.result.ResultData;
import com.itheima.vo.oss.PicUploadResult;
import lombok.extern.java.Log;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping
@Slf4j
public class OssController {

    @Autowired
    private PicUploadService picUploadService;

    @PostMapping("/aliyun/oss/upload")
    public ResultData upload(@RequestParam("photoFile") MultipartFile multipartFile) {
        log.info("上传图片。。。。。。。");
        PicUploadResult picUploadResult = this.picUploadService.upload(multipartFile);
        Map map=new HashMap();
        map.put("url",picUploadResult.getName());
        return ResultData.ok("操作成功",map);
    }

}
